#include <bits/stdc++.h>

using namespace std;

const int N = 3e5 + 10;

int n;
unsigned long long a[N],sum[N];

int main()
{
    cin >> n;
    for(int i = 1; i<= n; i++){
        cin >> a[i];
        sum[i] = sum[i -1] + a[i];
    }

   unsigned long long ans = 0;
    for(int i =1; i <= n; i++){
        ans += a[i] * (sum[n] - sum[i]);
    }
    cout << ans;
   
   return 0;
}
